自動化 workflow 建立後,必須具備即時的可觀測性。本篇介紹 Prometheus 收集器與 Grafana 儀表板的整合。
在 <JENKINS_IP> 啟動 Prometheus 容器,並配置 prometheus.yml 監控 Jenkins 與應用程式。
scrape_configs:
- job_name: 'jenkins'
metrics_path: '/jenkins/prometheus/'
static_configs:
- targets: ['<JENKINS_IP>:8080']
- job_name: 'dotnet-apps'
static_configs:
- targets: ['<SERVER_IP>:5000', '<SERVER_IP>:5000']
在 Jenkins 安裝 Prometheus metrics 外掛:
jenkins_executor_free_count: 監控建置節點是否滿載。jenkins_builds_success_total: 統計 workflow 成功率。建立 Grafana 容器並串接 Prometheus 資料源。
https://ci-cd.example.com/grafana/
在 Grafana 設定 Alert 規則,當 Quality Gate Fail 次數在 1 小時內超過 3 次時,發送通知給開發小組的 Email。
在程式碼量幾何增長的環境中,監控系統能及早偵測出異常的建置趨勢或部署失敗。透過數據分析,團隊能評估是否需要調整 AI 生成的規則或強化測試層面,實現數據驅動的 DevOps 管理。